Ext.define('PC.view.GridHembras', {
    extend:'Ext.grid.Panel',
    alias:'widget.GridHembras',
    id:'GridHembras',
    store:'HembrasStore',
//    height:250,
    title:'Hembras',

    initComponent:function () {
        var me = this;

        Ext.applyIf(me, {
            viewConfig:{

            },
            columns:[
                {
                    xtype:'gridcolumn',
                    flex:1,
                    text:'Arete',
                    dataIndex:'codigo'
                },
                {
                    xtype:'gridcolumn',
                    flex:1,
                    text:'Estado',
                    dataIndex:'id'
                }
            ],

            bbar:Ext.create('Ext.Toolbar', {
                items:[
                    '-',
                    {
                        text:'Add',
                        iconCls:'icon-add',
                        handler:function () {
                            var windows = Ext.create('Ext.window.Window', {
                                title:'Porcino',
                                width:400,
                                modal:true,
                                layout:'fit'
                            });

                            var form = Ext.create('PC.view.FormPorcino', {
                                saved:function (resp) {

                                    porcino = Ext.create('PC.model.Porcino');
                                    record = Ext.JSON.decode(resp.responseText);
                                    for (val in record) {
                                        porcino.set(val, record[val]);
                                    }
                                    porcino.internalId = record.id;
                                    //TODO review how to insert without sync
                                    me.getStore().insert(0, porcino);
//                                    me.getStore().load();                 1
                                    windows.close();
                                }
                            });

                            windows.add(form);
                            windows.show();
                        }
                    },
                    '-',
                    {
                        itemId:'delete',
                        text:'Delete',
                        iconCls:'icon-delete',
                        disabled:true,
                        handler:function () {
//                                            var selection = me.getSelectionModel().getSelection()[0];
//                                            if (selection) {
//                                                me.store.remove(selection);
//                                            }
                        }
                    }

                ]
            })


        });

        me.callParent(arguments);
    }

});